<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href="static/css/bootstrap.min.css" rel="stylesheet">
    <link href="static/img/png/Logo.png" type="image/png" rel="icon" sizes="192x192">

    <title>Edit</title>
</head>
<body style="background-color: rgba(0,0,0,0.4)">
<main class="container my-5 bg-white p-3 border shadow rounded">

<!-- The "modeEdit" indicate that part of template show to user -->
<!-- If "modeEdit" is True, show the form for edit the element-->
%if modeEdit:

    <nav class="navbar navbar-expand-md navbar-light bg-white mb-4 mx-4">
        <div class="container-fluid">
            <a class="navbar-brand fw-bold" href="/">Surorie</a>
        </div>
    </nav>

    <!-- template for editing a task-->
    <!-- the template expects to receive a value for "number" as well a "old", the text of the selected To-Do item-->
    <section class="px-4 mx-4">
        <p>Edit the task with ID = {{number}}</p>
        <form action="/edit/{{number}}" method="GET">
          <input class="form-control" type="text" name="task" value="{{old[0]}}" size="100" maxlength="100">
          <select class="mt-3 form-select" name="status">
            <option>open</option>
            <option>closed</option>
          </select>
          <br>
            <button class="mt-3 btn btn-primary" type="submit" name="save" value="save">Save</button>
        </form>
    </section>

    <footer class="text-center pt-3">
        <p class="text-muted small">Copyright: Joan &copy; 2020</p>
    </footer>

<!-- If "modeEdit" is False, show a message for indicate to user of
     successful of operation-->
%else:
    <section class="px-4 mx-4">
        <h6 class="h6 fw-bold border-bottom pb-3 my-3">Successful Operation</h6>
        <p class="text-muted">The item number {{number}} was successfully updated</p>
    </section>

    <script>
        // Redirect to user after of 3 seconds.
        setTimeout(()=> {
            window.location.href = '/';
        }, 3000)
    </script>
%end
</main>
<script src="static/js/bootstrap.bundle.min.js"></script>
</body>
</html>